#include "StdAfx.h"
#include "dcreateclassdlg.h"

DCreateClassDlg::DCreateClassDlg(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);

	QButtonGroup* pButtonGroup = new QButtonGroup(this);
	pButtonGroup->addButton(ui.radioPublic);
	pButtonGroup->addButton(ui.radioProtected);
	pButtonGroup->addButton(ui.radioPrivate);

	ui.radioPublic->setChecked(true);
	ui.editBaseClassName->setDisabled(true);

	QObject::connect(ui.editClassName, SIGNAL(textChanged(const QString&)), this, 
					SLOT(onClassTextChanged(const QString&)));
}

DCreateClassDlg::~DCreateClassDlg()
{

}

void DCreateClassDlg::update()
{
	QString text = ui.editBaseClassName->text();

	ui.radioPublic->setEnabled(!text.isEmpty());
	ui.radioProtected->setEnabled(!text.isEmpty());
	ui.radioPrivate->setEnabled(!text.isEmpty());
}

void DCreateClassDlg::onClassTextChanged(const QString& name)
{
	if(name.isEmpty())
	{
		ui.buttonOK->setEnabled(false);
	}
	else
	{
		ui.buttonOK->setEnabled(true);
	}
}